package com.example.covid19.controller;


import com.example.covid19.common.lang.Result;
import com.example.covid19.mapper.RechargeMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author BaiZhengChun
 * @since 2022-10-29
 */
@RestController
@RequestMapping("/recharge")
public class RechargeController {
    private final RechargeMapper rechargeMapper;

    public RechargeController(RechargeMapper rechargeMapper) {
        this.rechargeMapper = rechargeMapper;
    }

    @PostMapping("/Rinf")
    public Result Rinf(){
        return Result.success(200,"成功",rechargeMapper.getedch());
    }
    @PostMapping("/Rdl")
    public Result Rdl(@RequestParam("rechargeId")String rechargeId ){
        return Result.success(200,"成功",rechargeMapper.deleteById(rechargeId));
    }
    @PostMapping("/Cinf")
    public Result Cinf(){
        int i = rechargeMapper.selectCount(null);
        HashMap<Object,Object> map = new HashMap<>(2);
        map.put("count",i);
        map.put("info",rechargeMapper.gcharinf());
        return Result.success(200,"成功",map);
    }
    @PostMapping("/Cinf2")
    public Result Cinf2(@RequestParam("pageNo") Integer pageNo,@RequestParam("pagesize")Integer pagesize){
        int a = (pageNo-1)*pagesize;
        return Result.success(200,"成功",rechargeMapper.gcharinf2(a,pagesize));
    }

}
